<template>
  <div style="display: flex">
    <Card title="填写分类信息明细" dis-hover icon="md-document" style="flex: 1">
      <Form
        ref="FormData"
        :model="FormData"
        :rules="FormRules"
        :label-width="140"
      >
        <Row>
          <Col span="18" offset="3">
            <FormItem label="分类名称：" prop="categoryName">
              <Input v-model="FormData.categoryName" maxlength="20"
              show-word-limit placeholder="请输入分类名称"
              @keyup.native="specialChar('categoryName')"
            </FormItem>
          </Col>
          <Col span="18" offset="3">
            <FormItem label="分类编码：" prop="categoryNo">
              <Input
                v-model="FormData.categoryNo"
                disabled
                maxlength="15"
                show-word-limit
                placeholder="分类编码"
              ></Input>
            </FormItem>
          </Col>
          <Col span="18" offset="3">
            <FormItem label="位置：" prop="position">
              <InputNumber
                v-model="FormData.position"
                :precision="0"
                type="number"
                placeholder="位置"
                :max="999"
                :min="0"
              />
            </FormItem>
          </Col>
          <Col span="18" offset="3">
            <FormItem label="是否启用：" prop="state">
              <RadioGroup v-model="FormData.state">
                <Radio label="1">启用</Radio>
                <Radio label="2">不启用</Radio>
              </RadioGroup>
            </FormItem>
          </Col>
          <Col span="18" offset="3">
            <FormItem label="描述：">
              <Input
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 5 }"
                maxlength="50"
                show-word-limit
                v-model="FormData.categoryNote"
                placeholder="请输入描述"
              ></Input>
            </FormItem>
          </Col>
          <Col v-show="multipledata" span="18" offset="3">
            <Row type="flex">
              <FormItem label="限制类商品：" prop="categoryProductType">
                <RadioGroup v-model="FormData.categoryProductType">
                  <Radio label="1">危险品</Radio>
                  <Radio label="2">管制刀具</Radio>
                  <Radio label="3">非限制</Radio>
                </RadioGroup>
              </FormItem>
              <FormItem label="危化品等级：">
                <Select
                  v-model="FormData.dangerousOrder"
                  filterable
                  style="width: 200px"
                >
                  <Option
                    v-for="item in HCSList"
                    :value="item.value"
                    :key="item.value"
                    >{{ item.label }}
                  </Option>
                </Select>
              </FormItem>
            </Row>
            <Row>
              <FormItem label="关联商品模板：" prop="productTemplateNames">
                <Row type="flex">
                  <div class="qw-kuang"></div>
                </Row>
                <Input
                  v-model="FormData.productTemplateNames"
                  readonly
                  search
                  enter-button="选择"
                  @on-search="handleLink('template')"
                  placeholder="请选择"
                />
              </FormItem>
            </Row>
            <Row>
              <FormItem label="关联品牌：" prop="brandNames">
                <Input
                  v-model="FormData.brandNames"
                  readonly
                  search
                  enter-button="选择"
                  @on-search="handleLink('brand')"
                  placeholder="请选择"
                />
              </FormItem>
            </Row>
            <Row>
              <FormItem label="关联验收事项：" prop="acceptItemNames">
                <Input
                  v-model="FormData.acceptItemNames"
                  readonly
                  search
                  enter-button="选择"
                  @on-search="handleLink('gather')"
                  placeholder="请选择"
                />
              </FormItem>
            </Row>
            <Row>
              <FormItem label="关联归类名称：" prop="classificationNames">
                <Input
                  v-model="FormData.classificationNames"
                  readonly
                  search
                  enter-button="选择"
                  @on-search="handleLink('category')"
                  placeholder="请选择"
                />
              </FormItem>
            </Row>
            <!-- <Row>
              <FormItem label="关联场景模版：" prop="productSceneCategoryNames">
                <Input
                  v-model="FormData.productSceneCategoryNames"
                  readonly
                  search
                  enter-button="选择"
                  @on-search="handleLink('scene')"
                  placeholder="请选择"
                />
              </FormItem>
            </Row> -->
            <Row>
              <FormItem label="是否价格敏感：" prop="isPriceSensitive">
                <RadioGroup v-model="FormData.isPriceSensitive">
                  <Radio label="1">是</Radio>
                  <Radio label="2">否</Radio>
                </RadioGroup>
              </FormItem>
            </Row>
            <Row>
              <FormItem label="是否金属制品：" prop="isMetal">
                <RadioGroup v-model="FormData.isMetal">
                  <Radio label="1">是</Radio>
                  <Radio label="2">否</Radio>
                </RadioGroup>
              </FormItem>
            </Row>
            <Row>
              <FormItem label="是否重点：" prop="isKey">
                <RadioGroup v-model="FormData.isKey">
                  <Radio label="1">是</Radio>
                  <Radio label="2">否</Radio>
                </RadioGroup>
              </FormItem>
            </Row>
            <Row>
              <FormItem label="商品资质类型：">
                <Button type="primary" @click="handleLink('qualiByCommodity')"
                  >设置</Button
                >
              </FormItem>
            </Row>
            <Row>
              <FormItem label="分类资质类型：">
                <Button type="primary" @click="handleLink('qualiByClassify')"
                  >设置</Button
                >
              </FormItem>
            </Row>
            <Row>
              <FormItem label="批量订货额：">
                <InputNumber
                  v-model="FormData.batchOrderPrice"
                  :active-change="false"
                  :precision="2"
                  type="number"
                  placeholder=""
                  :max="999999999"
                  :min="0"
                  style="width: 150px"
                />
                元
              </FormItem>
            </Row>
          </Col>
          <Col span="18" offset="3">
            <FormItem>
              <Button
                @click="handleReset('FormData')"
                class="ivu-ml-8"
                style="margin-right: 20px"
                >取消</Button
              >
              <Button
                :loading="sLoading"
                type="primary"
                @click="handleSubmit('FormData')"
                >提交</Button
              >
            </FormItem>
          </Col>
        </Row>
      </Form>
    </Card>
    <!----------------------------关联属性模板---------------------------------->
    <Modal
      v-model="linkAttribute"
      width="1000"
      title="关联属性模板"
      @on-ok="closeModal()"
      @on-cancel="closeModal()"
      :closable="false"
    >
      <Card dis-hover>
        <Row type="flex" justify="start" align="bottom">
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">属性模板名称</span>
            <Input
              style="width: auto"
              v-model="name"
              placeholder="请输入属性模板名称"
            ></Input>
          </Col>
          <Col>
            <Button
              type="primary"
              style="margin-right: 10px"
              @click="linkAttributeBt('1')"
              >查询</Button
            >
            <Button @click="linkAttributeBt('0')">清空</Button>
          </Col>
        </Row>
      </Card>
      <Card dis-hover>
        <Row>
          <Tabs @on-click="linkAttributeChang" style="margin: 10px">
            <TabPane label="已关联" name="Name11">
              <!-- <Button type="success" size="small" style="margin:3px 0"
                                @click="bathDelFun('1')">批量取消关联</Button> -->
              <Table
                :columns="linkAttributeDataCol"
                :data="linkAttributeData"
                @on-select="handleBaseTablaeSelect($event, '1')"
                @on-select-all="handleSelectAll($event, '1')"
                @on-select-all-cancel="handleSelectAllCancel($event, '1')"
              >
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkAttributeSupply(row.uuid, '0')"
                    >取消</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkAttributeChang(linkAttributeValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
            <TabPane label="未关联" name="Name12">
              <!-- <Button type="success" size="small" style="margin:3px 0"
                                @click="bathCreateFun('1')">批量关联</Button> -->
              <Table
                :columns="linkAttributeDataCol"
                :data="linkAttributeData"
                @on-select="handleBaseTablaeSelect($event, '1')"
                @on-select-all="handleSelectAll($event, '1')"
                @on-select-all-cancel="handleSelectAllCancel($event, '1')"
              >
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkAttributeSupply(row.uuid, '1')"
                    >关联</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkAttributeChang(linkAttributeValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
          </Tabs>
        </Row>
      </Card>
    </Modal>
    <!----------------------------关联品牌---------------------------------->
    <Modal
      v-model="linkBrand"
      width="1000"
      title="关联品牌"
      @on-ok="closeModal()"
      @on-cancel="closeModal()"
      :closable="false"
    >
      <Card dis-hover>
        <Row type="flex" justify="start" align="bottom">
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">品牌名称</span>
            <Input
              style="width: auto"
              v-model="brandName"
              placeholder="请输入品牌名称"
            ></Input>
          </Col>
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">品牌英文名称</span>
            <Input
              style="width: auto"
              v-model="brandEnName"
              placeholder="请输入品牌英文名称"
            ></Input>
          </Col>
          <Col>
            <Button
              type="primary"
              style="margin-right: 10px"
              @click="linkBrandBt('1')"
              >查询</Button
            >
            <Button @click="linkBrandBt('0')">清空</Button>
          </Col>
        </Row>
      </Card>
      <Card dis-hover>
        <Row>
          <Tabs @on-click="linkBrandChang" style="margin: 10px">
            <TabPane label="已关联" name="Name11">
              <Button
                type="success"
                size="small"
                style="margin: 3px 0"
                @click="bathDelFun('2')"
                >批量取消关联</Button
              >
              <Table
                :columns="linkBrandDataCol"
                :data="linkBrandData"
                @on-select="handleBaseTablaeSelect($event, '2')"
                @on-select-all="handleSelectAll($event, '2')"
                @on-select-all-cancel="handleSelectAllCancel($event, '2')"
              >
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkBrandSupply(row.uuid, '0')"
                    >取消</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkBrandChang(linkBrandValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
            <TabPane label="未关联" name="Name12">
              <Button
                type="success"
                size="small"
                style="margin: 3px 0"
                @click="bathCreateFun('2')"
                >批量关联</Button
              >
              <Table
                :columns="linkBrandDataCol"
                :data="linkBrandData"
                @on-select="handleBaseTablaeSelect($event, '2')"
                @on-select-all="handleSelectAll($event, '2')"
                @on-select-all-cancel="handleSelectAllCancel($event, '2')"
              >
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkBrandSupply(row.uuid, '1')"
                    >关联</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkBrandChang(linkBrandValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
          </Tabs>
        </Row>
      </Card>
    </Modal>
    <!----------------------------关联验收事项---------------------------------->
    <Modal
      v-model="linkGather"
      width="1000"
      title="关联验收事项"
      @on-ok="closeModal()"
      @on-cancel="closeModal()"
      :closable="false"
    >
      <Card dis-hover>
        <Row type="flex" justify="start" align="bottom">
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">验收事项</span>
            <Input
              style="width: auto"
              v-model="itemName"
              placeholder="请输入验收事项"
            ></Input>
          </Col>
          <Col>
            <Button
              type="primary"
              style="margin-right: 10px"
              @click="linkGatherBt('1')"
              >查询</Button
            >
            <Button @click="linkGatherBt('0')">清空</Button>
          </Col>
        </Row>
      </Card>
      <Card dis-hover>
        <Row>
          <Tabs @on-click="linkGatherChang" style="margin: 10px">
            <TabPane label="已关联" name="Name11">
              <Button
                type="success"
                size="small"
                style="margin: 3px 0"
                @click="bathDelFun('5')"
                >批量取消关联</Button
              >
              <Table
                :columns="linkGatherDataCol"
                :data="linkGatherData"
                @on-select="handleBaseTablaeSelect($event, '5')"
                @on-select-all="handleSelectAll($event, '5')"
                @on-select-all-cancel="handleSelectAllCancel($event, '5')"
              >
                <template slot-scope="{ row, index }" slot="isNeedForPurchase">
                  <span v-if="row.isNeedForPurchase === '1'">是</span>
                  <span v-if="row.isNeedForPurchase === '2'">否</span>
                </template>
                <template slot-scope="{ row, index }" slot="isNeed">
                  <span v-if="row.isNeed === '1'">是</span>
                  <span v-if="row.isNeed === '2'">否</span>
                </template>
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkGatherSupply(row.uuid, index, '0')"
                    >取消</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkGatherChang(linkGatherValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
            <TabPane label="未关联" name="Name12">
              <Button
                type="success"
                size="small"
                style="margin: 3px 0"
                @click="bathCreateFun('5')"
                >批量关联</Button
              >
              <Table
                :columns="linkGatherDataCol"
                :data="linkGatherData"
                @on-select="handleBaseTablaeSelect($event, '5')"
                @on-select-all="handleSelectAll($event, '5')"
                @on-select-all-cancel="handleSelectAllCancel($event, '5')"
              >
                <template slot-scope="{ row, index }" slot="isNeedForPurchase">
                  <RadioGroup
                    v-model="row.isNeedForPurchase"
                    @on-change="onChageNeed(row, index)"
                  >
                    <Radio label="1">是</Radio>
                    <Radio label="2">否</Radio>
                  </RadioGroup>
                </template>
                <template
                  slot-scope="{ row, index }"
                  slot="isNeed"
                  @on-change="onChageNeed(row, index)"
                >
                  <RadioGroup v-model="row.isNeed">
                    <Radio label="1">是</Radio>
                    <Radio label="2">否</Radio>
                  </RadioGroup>
                </template>
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkGatherSupply(row.uuid, index, '1')"
                    >关联</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkGatherChang(linkGatherValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
          </Tabs>
        </Row>
      </Card>
    </Modal>
    <!----------------------------关联归类模板---------------------------------->
    <Modal
      v-model="linkCategory"
      width="1000"
      title="关联税类模板"
      @on-ok="closeModal()"
      @on-cancel="closeModal()"
      :closable="false"
    >
      <Card dis-hover>
        <Row type="flex" justify="start" align="bottom">
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">归类名称</span>
            <Input
              style="width: auto"
              v-model="classificationName"
              placeholder="请输入归类名称"
            ></Input>
          </Col>
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">税类名称</span>
            <Input
              style="width: auto"
              v-model="taxCateName"
              placeholder="请输入税类名称"
            ></Input>
          </Col>
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">税类编码</span>
            <Input
              style="width: auto"
              v-model="taxCateNo"
              placeholder="请输入税类编码"
            ></Input>
          </Col>
          <Col style="padding: 10px 0">
            <Button
              type="primary"
              style="margin-right: 10px"
              @click="linkCategoryBt('1')"
              >查询</Button
            >
            <Button @click="linkCategoryBt('0')">清空</Button>
          </Col>
        </Row>
      </Card>
      <Card dis-hover>
        <Row>
          <Tabs @on-click="linkCategoryChang" style="margin: 10px">
            <TabPane label="已关联" name="Name11">
              <Button
                type="success"
                size="small"
                style="margin: 3px 0"
                @click="bathDelFun('3')"
                >批量取消关联</Button
              >
              <Table
                :columns="linkCategoryDataCol"
                border
                :data="linkCategoryData"
                @on-select="handleBaseTablaeSelect($event, '3')"
                @on-select-all="handleSelectAll($event, '3')"
                @on-select-all-cancel="handleSelectAllCancel($event, '3')"
              >
                <template slot-scope="{ row, index }" slot="state">
                  <span v-if="row.state === '1'">未审核</span>
                  <span v-if="row.state === '2'">通过</span>
                  <span v-if="row.state === '3'">未通过</span>
                </template>
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkCategorySupply(row.uuid, '0')"
                    >取消</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkCategoryChang(linkCategoryValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
            <TabPane label="未关联" name="Name12">
              <Button
                type="success"
                size="small"
                style="margin: 3px 0"
                @click="bathCreateFun('3')"
                >批量关联</Button
              >
              <Table
                :columns="linkCategoryDataCol"
                border
                :data="linkCategoryData"
                @on-select="handleBaseTablaeSelect($event, '3')"
                @on-select-all="handleSelectAll($event, '3')"
                @on-select-all-cancel="handleSelectAllCancel($event, '3')"
              >
                <template slot-scope="{ row, index }" slot="state">
                  <span v-if="row.state === '1'">未审核</span>
                  <span v-if="row.state === '2'">通过</span>
                  <span v-if="row.state === '3'">未通过</span>
                </template>
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkCategorySupply(row.uuid, '1')"
                    >关联</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkCategoryChang(linkCategoryValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
          </Tabs>
        </Row>
      </Card>
    </Modal>
    <!----------------------------关联场景分类开始---------------------------------->
    <Modal
      v-model="linkScene"
      width="1000"
      title="关联场景模板"
      @on-ok="closeModal()"
      @on-cancel="closeModal()"
      :closable="false"
    >
      <Card dis-hover>
        <Row type="flex" justify="start" align="bottom">
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">二级场景分类名称</span>
            <Input
              style="width: auto"
              v-model="categoryName"
              placeholder="请输入二级场景分类"
            ></Input>
          </Col>
          <Col style="margin-right: 40px">
            <span style="margin-right: 10px">一级场景分类名称</span>
            <Input
              style="width: auto"
              v-model="parentName"
              placeholder="请输入一级场景分类"
            ></Input>
          </Col>
          <Col>
            <Button
              type="primary"
              style="margin-right: 10px"
              @click="linkSceneBt('1')"
              >查询</Button
            >
            <Button @click="linkSceneBt('0')">清空</Button>
          </Col>
        </Row>
      </Card>
      <Card dis-hover>
        <Row>
          <Tabs @on-click="linkSceneChang" style="margin: 10px">
            <TabPane label="已关联" name="Name11">
              <Button
                type="success"
                size="small"
                style="margin: 3px 0"
                @click="bathDelFun('4')"
                >批量取消关联</Button
              >
              <Table
                :columns="linkSceneDataCol"
                border
                :data="linkSceneData"
                @on-select="handleBaseTablaeSelect($event, '4')"
                @on-select-all="handleSelectAll($event, '4')"
                @on-select-all-cancel="handleSelectAllCancel($event, '4')"
              >
                <template slot-scope="{ row, index }" slot="categoryState">
                  <span v-if="row.categoryState === '1'">启用</span>
                  <span v-if="row.categoryState === '2'">未启用</span>
                </template>
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkSceneSupply(row.uuid, '0')"
                    >取消</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkSceneChang(linkSceneValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
            <TabPane label="未关联" name="Name12">
              <Button
                type="success"
                size="small"
                style="margin: 3px 0"
                @click="bathCreateFun('4')"
                >批量关联</Button
              >
              <Table
                :columns="linkSceneDataCol"
                border
                :data="linkSceneData"
                @on-select="handleBaseTablaeSelect($event, '4')"
                @on-select-all="handleSelectAll($event, '4')"
                @on-select-all-cancel="handleSelectAllCancel($event, '4')"
              >
                <template slot-scope="{ row, index }" slot="categoryState">
                  <span v-if="row.categoryState === '1'">启用</span>
                  <span v-if="row.categoryState === '2'">未启用</span>
                </template>
                <template slot-scope="{ row, index }" slot="action">
                  <Button
                    type="success"
                    size="small"
                    style="margin: 3px 0"
                    @click="linkSceneSupply(row.uuid, '1')"
                    >关联</Button
                  >
                </template>
              </Table>
              <div class="ivu-mt ivu-text-center">
                <Page
                  :total="totalNum"
                  show-total
                  show-sizer
                  :current.sync="nowPage"
                  @on-change="linkSceneChang(linkSceneValue)"
                  @on-page-size-change="handleChangePage"
                />
              </div>
            </TabPane>
          </Tabs>
        </Row>
      </Card>
    </Modal>
    <!----------------------------关联场景分类结束---------------------------------->
    <!----------------------------商品资质类型---------------------------------->
    <Modal
      v-model="qualiByCommodity"
      width="1000"
      title="商品资质类型"
      @on-ok="closeModal()"
      @on-cancel=""
    >
      <Card dis-hover>
        <Row>
          <Table
            ref="selection"
            border
            :columns="qualiByCommodityCol"
            :data="qualiByCommodityData"
            @on-selection-change="qualiByCommodityFun"
          >
            <template slot-scope="{ row, index }" slot="mustHave">
              <RadioGroup v-model="row.mustHave">
                <Radio label="1">是</Radio>
                <Radio label="2">否</Radio>
              </RadioGroup>
            </template>
          </Table>
        </Row>
      </Card>
    </Modal>
    <!----------------------------分类资质类型---------------------------------->
    <Modal
      v-model="qualiByClassify"
      width="1000"
      title="分类资质类型"
      @on-ok="closeModal()"
      @on-cancel=""
    >
      <Card dis-hover>
        <Row>
          <Table
            ref="selection"
            border
            :columns="qualiByClassifyCol"
            :data="qualiByClassifyData"
            @on-selection-change="qualiByClassifyFun"
          >
            <template slot-scope="{ row, index }" slot="mustHave">
              <RadioGroup v-model="row.mustHave">
                <Radio label="1">是</Radio>
                <Radio label="2">否</Radio>
              </RadioGroup>
            </template>
          </Table>
        </Row>
      </Card>
    </Modal>
  </div>
</template>
<script>
import { mapState, mapMutations } from 'vuex';
import util from '@/libs/util';
import bus from '@/mixins/bus';
import { ApiRequest } from '@api/basePage';

export default {
  components: {},
  data () {
    return {
      linkAttribute: false,
      linkBrand: false,
      linkGather: false,
      linkCategory: false,
      linkScene: false,
      qualiByCommodity: false,
      qualiByClassify: false,
      ceshi: true,
      totalNum: 0,
      nowPage: 1,
      pageShow: 10, // 每页展示条数
      name: '',
      brandName: '',
      brandEnName: '',
      itemName: '',
      classificationName: '',
      taxCateName: '',
      taxCateNo: '',
      categoryName: '',
      parentName: '',
      isOnelevelNum: true,
      TypeList: [
        {
          value: '1',
          label: '产品使用'
        },
        {
          value: '2',
          label: '供应商使用'
        },
        {
          value: '3',
          label: '产品/供应商共用'
        }
      ],
      linkAttributeValue: 'Name11',
      linkAttributeDataCol: [
        // {
        //     type: 'selection',
        //     width: 60,
        //     align: 'center'
        // },
        {
          title: '属性模板名称',
          key: 'name'
        },
        {
          title: '属性分类名称',
          key: 'categoryName'
        },
        {
          title: '模板描述',
          key: 'note'
        },
        {
          title: '操作',
          slot: 'action',
          align: 'center',
          minWidth: 120
        }
      ],
      linkBrandValue: 'Name11',
      linkBrandDataCol: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '品牌名称',
          key: 'brandName'
        },
        {
          title: '品牌英文名称',
          key: 'brandEnName'
        },
        {
          title: '品牌描述',
          key: 'note'
        },
        {
          title: '操作',
          slot: 'action',
          align: 'center',
          minWidth: 120
        }
      ],
      linkGatherValue: 'Name11',
      linkGatherDataCol: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '验收事项名称',
          key: 'itemName'
        },
        {
          title: '临采商品是否必填',
          slot: 'isNeedForPurchase'
        },
        {
          title: '非临采商品是否必填',
          slot: 'isNeed'
        },
        {
          title: '操作',
          slot: 'action',
          align: 'center',
          minWidth: 120
        }
      ],
      linkCategoryValue: 'Name11',
      linkCategoryDataCol: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '归类名称',
          key: 'classificationName'
        },
        {
          title: '税类名称',
          key: 'taxCateName'
        },
        {
          title: '税类编码',
          key: 'taxCateNo'
        },
        {
          title: '税率',
          key: 'taxRate'
        },
        {
          title: '审核状态',
          slot: 'state'
        },
        {
          title: '描述',
          key: 'note'
        },
        {
          title: '操作',
          slot: 'action',
          align: 'center',
          minWidth: 120
        }
      ],
      linkSceneValue: 'Name11',
      linkSceneDataCol: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '二级场景分类名称',
          key: 'categoryName'
        },
        {
          title: '一级场景分类名称',
          key: 'parentName'
        },
        {
          title: '启用状态',
          slot: 'categoryState'
        },
        {
          title: '模板描述',
          key: 'categoryDesc'
        },
        {
          title: '操作',
          slot: 'action',
          align: 'center',
          minWidth: 120
        }
      ],
      qualiByCommodityCol: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '分类资质类型',
          key: 'qualificationTypeName'
        },
        {
          title: '是否必填',
          slot: 'mustHave'
        }
      ],
      qualiByClassifyCol: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '分类资质类型',
          key: 'qualificationTypeName'
        },
        {
          title: '是否必填',
          slot: 'mustHave'
        }
      ],
      qualiByCommodityData: [],
      qualiByClassifyData: [],
      linkAttributeData: [],
      linkBrandData: [],
      linkGatherData: [],
      linkCategoryData: [],
      linkSceneData: [],
      multipledata: false,
      isRootCategory: false,
      showRight: false,
      showCategory: true,
      HCSList: [
        {
          value: '1',
          label: '一级'
        },
        {
          value: '2',
          label: '二级'
        },
        {
          value: '3',
          label: '三级'
        }
      ],
      util: util,
      dynamicData: {},
      pagePath: '', // 当前路由
      FormRules: {
        categoryName: [
          { required: true, message: '请填写分类名称', trigger: 'blur' },
          {
            type: 'string',
            min: 1,
            max: 20,
            message: '分类名称不得少于1个字符,且不能大于20个字符',
            trigger: 'blur'
          }
        ],
        categoryNo: [
          { required: true, message: '请填写分类编码', trigger: 'blur' },
          {
            type: 'string',
            min: 1,
            max: 15,
            message: '分类编码不得少于1个字符,且不能大于15个字符',
            trigger: 'blur'
          }
        ],
        position: [
          { required: true, message: '请填写位置', trigger: 'blur' },
          {
            type: 'string',
            min: 1,
            max: 3,
            message: '位置不得少于1个字符,且不能大于3个字符',
            trigger: 'blur'
          }
        ],
        categoryNote: [
          { required: true, message: '请填写描述', trigger: 'blur' },
          {
            type: 'string',
            min: 1,
            max: 50,
            message: '描述不得少于一个字符,,且不能大于50个字符',
            trigger: 'blur'
          }
        ],
        state: [
          { required: true, message: '启用状态不能为空', trigger: 'blur' }
        ],
        categoryProductType: [
          { required: true, message: '限制类型', trigger: 'blur' }
        ],
        // dangerousOrder: [{ required: true, message: '危险品等级不能为空', trigger: 'blur' }],
        productTemplateNames: [
          { required: true, message: '关联商品模板不能为空', trigger: 'blur' }
        ],
        brandNames: [{ required: true, message: '关联品牌不能为空' }],
        acceptItemNames: [{ required: true, message: '关联验收事项不能为空' }],
        classificationNames: [
          { required: true, message: '关联归类事项不能为空' }
        ],
        /* productSceneCategoryNames: [
          { required: true, message: '关联场景模板不能为空' }
        ], */
        isPriceSensitive: [
          { required: true, message: '是否价格敏感不能为空', trigger: 'blur' }
        ],
        isMetal: [
          { required: true, message: '是否金属制品不能为空', trigger: 'blur' }
        ],
        isKey: [
          { required: true, message: '是否重点不能为空', trigger: 'blur' }
        ],
        batchOrderPrice: [
          { required: true, message: '请填写批量订货额', trigger: 'blur' }
        ]
      },
      FormData: {
        parentUuid: 'systemUuid',
        categoryName: '',
        categoryNo: '',
        categoryNote: '',
        levelNum: '',
        position: 0,
        state: '',
        uuid: '',
        categoryProductType: '',
        dangerousOrder: '',
        isPriceSensitive: '',
        isMetal: '',
        isKey: '',
        batchOrderPrice: 0,
        templateUuids: [],
        productTemplateNames: '',
        brandNames: '',
        brandUuids: [],
        acceptItemNames: '',
        acceptItemUuids: [],
        classificationUuids: [],
        classificationNames: '',
        productSceneCategoryUuids: [],
        productSceneCategoryNames: '',
        listQualificationTypes: [] // 资质的数据
      },
      templateUuids: [],
      templateNames: [],
      brandUuids: [],
      brandNames: [],
      acceptItemNames: [],
      acceptItemUuids: [],
      classificationUuids: [],
      classificationNames: [],
      productSceneCategoryUuids: [],
      productSceneCategoryNames: [],
      rootDate: [],
      sLoading: false,
      uuid: '',
      templateUuidList: [], // 模板批量处理的数据
      brandUuidList: [], // 品牌批量处理数据
      relUuidsList: [], // 归类批量处理数据
      scenecategoryUuidList: [], // 场景批量处理数据
      relateUuidsList: [] // 验收事项
    };
  },
  watch: {
    $route: function () {
      this.$nextTick(() => {
        this.$router.go(0);
      });
    }
  },
  created () {
    this.getConfigData();
  },
  mounted () {},
  methods: {
    // 控制不能输入特殊字符
    specialChar (name) {
      this.FormData[name] = this.FormData[name]
        .replace(
          /[`~!@#$%^&*()_\-+=<>?:"{}|,./;'\\[\]·~！@#￥%……&*（）——\-+={}|《》？：“”【】、；‘’，。、]/g,
          ''
        )
        .replace(/\s/g, '');
    },
    // 批量关联接口
    bathCreateFun (type) {
      if (type === '1') {
        // 模板
        if (this.templateUuidList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          platCategoryUuid: this.uuid,
          templateUuidList: this.templateUuidList.join(',')
        };
        // 创建分类
        ApiRequest(
          this.requestApi.bathCreatePlatCategoryAndTemplate.url,
          this.requestApi.bathCreatePlatCategoryAndTemplate.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkAttributeChang(this.linkAttributeValue);
          }
        });
      } else if (type === '2') {
        if (this.brandUuidList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          platCategoryUuid: this.uuid,
          brandUuidList: this.brandUuidList.join(',')
        };
        ApiRequest(
          this.requestApi.bathCreatePlatCategoryAndBrandPp.url,
          this.requestApi.bathCreatePlatCategoryAndBrandPp.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkBrandChang(this.linkBrandValue);
          }
        });
      } else if (type === '3') {
        if (this.relUuidsList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          categoryUuid: this.uuid,
          relUuids: this.relUuidsList.join(',')
        };
        // 创建分类
        ApiRequest(
          this.requestApi.createRelateByCateGl.url,
          this.requestApi.createRelateByCateGl.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkCategoryChang(this.linkCategoryValue);
          }
        });
      } else if (type === '4') {
        if (this.scenecategoryUuidList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          categoryUuid: this.uuid,
          relUuids: this.scenecategoryUuidList.join(',')
        };
        ApiRequest(
          this.requestApi.createRelateCj.url,
          this.requestApi.createRelateCj.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkSceneChang(this.linkSceneValue);
          }
        });
      } else if (type === '5') {
        if (this.relateUuidsList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          categoryUuid: this.uuid,
          relUuids: this.relateUuidsList.join(',')
        };
        ApiRequest(
          this.requestApi.createRelateYs.url + '?categoryUuid=' + this.uuid,
          this.requestApi.createRelateYs.type,
          this.linkGatherData,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkGatherChang(this.linkGatherValue);
          }
        });
      }
    },
    // 批量取消关联接口
    bathDelFun (type) {
      if (type === '1') {
        // 模板
        if (this.templateUuidList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          platCategoryUuid: this.uuid,
          templateUuidList: this.templateUuidList.join(',')
        };
        // 创建分类
        ApiRequest(
          this.requestApi.deleteRelation.url,
          this.requestApi.deleteRelation.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkAttributeChang(this.linkAttributeValue);
          }
        });
      } else if (type === '2') {
        if (this.brandUuidList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          platCategoryUuid: this.uuid,
          brandUuidList: this.brandUuidList.join(',')
        };
        ApiRequest(
          this.requestApi.deleteRelationPp.url,
          this.requestApi.deleteRelationPp.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkBrandChang(this.linkBrandValue);
          }
        });
      } else if (type === '3') {
        if (this.relUuidsList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          categoryUuid: this.uuid,
          relUuids: this.relUuidsList.join(',')
        };
        // 创建分类
        ApiRequest(
          this.requestApi.deleteRelateGl.url,
          this.requestApi.deleteRelateGl.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkCategoryChang(this.linkCategoryValue);
          }
        });
      } else if (type === '4') {
        if (this.scenecategoryUuidList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          categoryUuid: this.uuid,
          relUuids: this.scenecategoryUuidList.join(',')
        };
        ApiRequest(
          this.requestApi.deleteRelateCj.url,
          this.requestApi.deleteRelateCj.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkSceneChang(this.linkSceneValue);
          }
        });
      } else if (type === '5') {
        if (this.relateUuidsList.length === 0) {
          this.$Message.error('请选择要操作的数据!');
          return;
        }
        let data = {
          categoryUuid: this.uuid,
          relUuids: this.relateUuidsList.join(',')
        };
        ApiRequest(
          this.requestApi.deleteRelateYs.url,
          this.requestApi.deleteRelateYs.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkGatherChang(this.linkGatherValue);
          }
        });
      }
    },
    // 全选
    handleSelectAll (row, type) {
      this.templateUuidList = [];
      this.brandUuidList = [];
      this.relUuidsList = [];
      this.scenecategoryUuidList = [];
      this.relateUuidsList = [];
      if (type === '1') {
        // 模板
        row.forEach(element => {
          this.templateUuidList.push(element.uuid);
        });
      } else if (type === '2') {
        row.forEach(element => {
          this.brandUuidList.push(element.uuid);
        });
      } else if (type === '3') {
        row.forEach(element => {
          this.relUuidsList.push(element.uuid);
        });
      } else if (type === '4') {
        row.forEach(element => {
          this.scenecategoryUuidList.push(element.uuid);
        });
      } else if (type === '5') {
        row.forEach(element => {
          this.relateUuidsList.push(element.uuid);
        });
      }
    },
    // 取消全选
    handleSelectAllCancel (row, type) {
      if (type === '1') {
        this.templateUuidList = [];
      } else if (type === '2') {
        this.brandUuidList = [];
      } else if (type === '3') {
        this.relUuidsList = [];
      } else if (type === '4') {
        this.scenecategoryUuidList = [];
      } else if (type === '5') {
        this.relateUuidsList = [];
      }
    },
    // 单独选择操作
    handleBaseTablaeSelect (row, type) {
      if (type === '1') {
        // 模板
        this.templateUuidList = [];
        row.forEach(element => {
          this.templateUuidList.push(element.uuid);
        });
      } else if (type === '2') {
        this.brandUuidList = [];
        row.forEach(element => {
          this.brandUuidList.push(element.uuid);
        });
      } else if (type === '3') {
        this.relUuidsList = [];
        row.forEach(element => {
          this.relUuidsList.push(element.uuid);
        });
      } else if (type === '4') {
        this.scenecategoryUuidList = [];
        row.forEach(element => {
          this.scenecategoryUuidList.push(element.uuid);
        });
      } else if (type === '5') {
        this.relateUuidsList = [];
        row.forEach(element => {
          this.relateUuidsList.push(element.uuid);
        });
      }
    },
    onChageNeed (row, index) {
      this.linkGatherData[index] = row;
    },
    // 获取初始配置信息
    getConfigData () {
      this.pagePath = this.$route.path;
      let dynamicData = require('./configjs/categoryAdd').default;
      this.requestApi = dynamicData.requestApi; // 页面所需接口集合
      this.$set(this.$data, 'dynamicData', dynamicData);
      this.uuid = this.$route.query.uuid;
      this.initData();
    },
    // 初始化数的数据
    initData (formData) {
      let data = {
        platCategoryUuid: this.uuid
      };
      ApiRequest(
        this.requestApi.getPlatCategoryByUuid.url,
        this.requestApi.getPlatCategoryByUuid.type,
        data,
        true
      ).then(res => {
        if (res.retStatus === '1') {
          this.FormData.categoryName = res.retData.categoryName;
          this.FormData.categoryNo = res.retData.categoryNo;
          this.FormData.categoryNote = res.retData.categoryNote;
          this.FormData.position = res.retData.position;
          this.FormData.state = res.retData.state;
          this.FormData.levelNum = res.retData.levelNum;
          if (res.retData.levelNum === '4') {
            this.multipledata = true;
          } else {
            this.multipledata = false;
          }
          this.FormData.uuid = res.retData.uuid;
          this.FormData.parentUuid = res.retData.parentUuid;
          this.FormData.categoryProductType = res.retData.categoryProductType;
          this.FormData.dangerousOrder = res.retData.dangerousOrder;
          this.FormData.isPriceSensitive = res.retData.isPriceSensitive;
          this.FormData.isMetal = res.retData.isMetal;
          this.FormData.isKey = res.retData.isKey;
          this.FormData.categoryType = res.retData.categoryType;
          this.FormData.batchOrderPrice = res.retData.batchOrderPrice;
          this.FormData.templateUuids = res.retData.templateUuids;
          this.FormData.brandUuids = res.retData.brandUuids;
          this.FormData.acceptItemUuids = res.retData.acceptItemUuids;
          this.FormData.classificationUuids = res.retData.classificationUuids;
          this.FormData.productSceneCategoryUuids =
            res.retData.productSceneCategoryUuids;
          this.FormData.productTemplateNames = res.retData.productTemplateNames;
          this.FormData.brandNames = res.retData.brandNames;
          this.FormData.acceptItemNames = res.retData.acceptItemNames;
          this.FormData.classificationNames = res.retData.classificationNames;
          this.FormData.productSceneCategoryNames =
            res.retData.productSceneCategoryNames;
          this.FormData.listQualificationTypes =
            res.retData.listQualificationTypes;
          this.qualiByCommodityData = [];
          this.qualiByClassifyData = [];
          res.retData.listQualificationTypes.forEach(element => {
            if (element.relType === '1') {
              // 商品资质类型
              this.qualiByCommodityData.push(element);
            } else {
              this.qualiByClassifyData.push(element);
            }
          });
        }
      });
    },
    // 获取表格数据
    getData (formData) {
      this.$refs.table.getData(formData);
    },
    // 点击 关联子分类
    clickChildCategory () {
      this.multipledata = false;
      this.isRootCategory = false;
      this.showRight = true;
      this.isOnelevelNum = false;
    },
    // 点击添加根分类
    clickRootCategory () {
      // this.multipledata = true;
      this.multipledata = false;
      this.isRootCategory = true;
      this.showRight = true;
      this.isOnelevelNum = true;
    },
    // 选择关联
    handleLink (e) {
      let link = e;
      this.linkAttributeValue = 'Name11';
      if (link == 'template') {
        this.name = '';
        this.linkAttribute = true;
        this.linkAttributeChang(this.linkAttributeValue);
      } else if (link == 'brand') {
        this.brandName = '';
        this.brandEnName = '';
        this.linkBrand = true;
        this.linkBrandChang(this.linkBrandValue);
      } else if (link == 'gather') {
        this.itemName = '';
        this.linkGather = true;
        this.linkGatherChang(this.linkGatherValue);
      } else if (link == 'category') {
        this.classificationName = '';
        this.taxCateName = '';
        this.taxCateNo = '';
        this.linkCategory = true;
        this.linkCategoryChang(this.linkCategoryValue);
      } else if (link == 'scene') {
        this.categoryName = '';
        this.parentName = '';
        this.linkScene = true;
        this.linkSceneChang(this.linkSceneValue);
      } else if (link == 'qualiByCommodity') {
        this.qualiByCommodity = true;
        this.qualiByCommodityData = [];
      } else if (link == 'qualiByClassify') {
        this.qualiByClassify = true;
        this.qualiByClassifyData = [];
      }
    },
    linkAttributeChang (name) {
      this.linkAttributeValue = name;
      let searchParam = [];
      searchParam.push({ name: 'name', value: this.name });
      searchParam.push({ name: 'name_q', value: 'Like' });
      let data = {
        nowPage: this.nowPage,
        pageShow: this.pageShow,
        searchParam: JSON.stringify(searchParam),
        sortName: '',
        sortType: ''
      };
      if (name === 'Name11') {
        ApiRequest(
          this.requestApi.getRelByCondition.url + '?categoryUuid=' + this.uuid,
          this.requestApi.getRelByCondition.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkAttributeData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      } else {
        ApiRequest(
          this.requestApi.getNotRelByCondition.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getNotRelByCondition.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkAttributeData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      }
    },
    // 品牌
    linkBrandChang (name) {
      this.linkBrandValue = name;
      let searchParam = [];
      searchParam.push({ name: 'brandName', value: this.brandName });
      searchParam.push({ name: 'brandName_q', value: 'Like' });
      searchParam.push({ name: 'brandEnName', value: this.brandEnName });
      searchParam.push({ name: 'brandEnName_q', value: 'Like' });
      let data = {
        nowPage: this.nowPage,
        pageShow: this.pageShow,
        searchParam: JSON.stringify(searchParam),
        sortName: '',
        sortType: ''
      };
      if (name === 'Name12') {
        ApiRequest(
          this.requestApi.getBrandNotRelByConditionPp.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getBrandNotRelByConditionPp.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkBrandData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      } else {
        ApiRequest(
          this.requestApi.getBrandRelByConditionPp.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getBrandRelByConditionPp.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkBrandData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      }
    },
    linkGatherChang (name) {
      this.linkGatherValue = name;
      let searchParam = [];
      searchParam.push({ name: 'itemName', value: this.itemName });
      searchParam.push({ name: 'itemName_q', value: 'Like' });
      let data = {
        nowPage: this.nowPage,
        pageShow: this.pageShow,
        searchParam: JSON.stringify(searchParam),
        sortName: '',
        sortType: ''
      };
      if (name === 'Name12') {
        ApiRequest(
          this.requestApi.getNotRelByConditionYs.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getNotRelByConditionYs.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            res.retData.results.forEach(element => {
              element.isNeedForPurchase = '1';
              element.isNeed = '1';
              element.acceptItemUuid = element.uuid;
            });
            this.linkGatherData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      } else {
        ApiRequest(
          this.requestApi.getRelByConditionYs.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getRelByConditionYs.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            res.retData.results.forEach(element => {
              element.isNeedForPurchase = '1';
              element.isNeed = '1';
              element.acceptItemUuid = element.uuid;
            });
            this.linkGatherData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      }
    },
    linkCategoryChang (name) {
      this.linkCategoryValue = name;
      let searchParam = [];
      searchParam.push({
        name: 'classificationName',
        value: this.classificationName
      });
      searchParam.push({ name: 'classificationName_q', value: 'Like' });
      searchParam.push({ name: 'taxCateName', value: this.taxCateName });
      searchParam.push({ name: 'taxCateName_q', value: 'Like' });
      searchParam.push({ name: 'taxCateNo', value: this.taxCateNo });
      searchParam.push({ name: 'taxCateNo_q', value: 'Like' });
      let data = {
        nowPage: this.nowPage,
        pageShow: this.pageShow,
        searchParam: JSON.stringify(searchParam),
        sortName: '',
        sortType: ''
      };
      if (name === 'Name12') {
        ApiRequest(
          this.requestApi.getNotRelByConditionGl.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getRelByConditionGl.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkCategoryData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      } else {
        ApiRequest(
          this.requestApi.getRelByConditionGl.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getRelByConditionGl.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkCategoryData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      }
    },
    linkSceneChang (name) {
      this.linkSceneValue = name;
      let searchParam = [];
      searchParam.push({ name: 'categoryName', value: this.categoryName });
      searchParam.push({ name: 'categoryName_q', value: 'Like' });
      searchParam.push({ name: 'parentName', value: this.parentName });
      searchParam.push({ name: 'parentName_q', value: 'Like' });
      let data = {
        nowPage: this.nowPage,
        pageShow: this.pageShow,
        searchParam: JSON.stringify(searchParam),
        sortName: '',
        sortType: ''
      };
      if (name === 'Name12') {
        ApiRequest(
          this.requestApi.getNotRelByConditionCj.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getNotRelByConditionCj.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkSceneData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      } else {
        ApiRequest(
          this.requestApi.getRelByConditionCj.url +
            '?categoryUuid=' +
            this.uuid,
          this.requestApi.getRelByConditionCj.type,
          data,
          false
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkSceneData = res.retData.results;
            this.totalNum = res.retData.totalNum;
          }
        });
      }
    },
    linkAttributeFun (row) {
      this.templateUuids = [];
      this.templateNames = [];
      row.forEach(item => {
        this.templateUuids.push(item.uuid);
        this.templateNames.push(item.name);
      });
      this.FormData.productTemplateNames = this.templateNames.join(',');
      this.FormData.templateUuids = this.templateUuids;
    },
    linkAttributeBt (type) {
      if (type === '0') {
        this.name = '';
      }
      this.linkAttributeChang(this.linkAttributeValue);
    },
    linkBrandBt (type) {
      if (type === '0') {
        this.brandName = '';
        this.brandEnName = '';
      }
      this.linkBrandChang(this.linkBrandValue);
    },
    linkGatherBt (type) {
      if (type === '0') {
        this.itemName = '';
      }
      this.linkGatherChang(this.linkGatherValue);
    },
    linkCategoryBt (type) {
      if (type === '0') {
        this.classificationName = '';
        this.taxCateName = '';
        this.taxCateNo = '';
      }
      this.linkCategoryChang(this.linkCategoryValue);
    },
    linkSceneBt (type) {
      if (type === '0') {
        this.categoryName = '';
        this.parentName = '';
      }
      this.linkSceneChang(this.linkSceneValue);
    },
    handleSubmit () {
      if (
        this.FormData.categoryName === '' ||
        this.FormData.categoryName === null ||
        this.FormData.categoryName === undefined
      ) {
        this.$Message.error('分类名称不能为空!');
        return;
      }
      if (
        this.FormData.categoryNo === '' ||
        this.FormData.categoryNo === null ||
        this.FormData.categoryNo === undefined
      ) {
        this.$Message.error('分类编码不能为空!');
        return;
      }
      if (
        this.FormData.position === '' ||
        this.FormData.position === null ||
        this.FormData.position === undefined
      ) {
        this.$Message.error('位置不能为空!');
        return;
      }
      if (this.multipledata) {
        // 创建根分类
        if (this.FormData.categoryProductType !== '3') {
          if (
            this.FormData.dangerousOrder !== '1' &&
            this.FormData.dangerousOrder !== '2' &&
            this.FormData.dangerousOrder !== '3'
          ) {
            this.$Message.error('请完善危险品等级后再提交!');
            return;
          }
        }
        if (
          this.FormData.batchOrderPrice === '' ||
          this.FormData.batchOrderPrice === null ||
          this.FormData.batchOrderPrice === undefined
        ) {
          this.$Message.error('请完善批量订货额后再提交!');
          return;
        }
        if (
          this.FormData.productTemplateNames === '' ||
          this.FormData.productTemplateNames === null ||
          this.FormData.productTemplateNames === undefined
        ) {
          this.$Message.error('请完善商品模板后再提交!');
          return;
        }
        if (
          this.FormData.brandNames === '' ||
          this.FormData.brandNames === null ||
          this.FormData.brandNames === undefined
        ) {
          this.$Message.error('请关联品牌后再提交!');
          return;
        }
        if (
          this.FormData.acceptItemNames === '' ||
          this.FormData.acceptItemNames === null ||
          this.FormData.acceptItemNames === undefined
        ) {
          this.$Message.error('请完善验收事项后再提交!');
          return;
        }
        if (
          this.FormData.classificationNames === '' ||
          this.FormData.classificationNames === null ||
          this.FormData.classificationNames === undefined
        ) {
          this.$Message.error('请完善归类名称后再提交!');
          return;
        }
        /* if (
          this.FormData.productSceneCategoryNames === '' ||
          this.FormData.productSceneCategoryNames === null ||
          this.FormData.productSceneCategoryNames === undefined
        ) {
          this.$Message.error('请完善场景模板后再提交!');
          return;
        } */
        // this.FormData.parentUuid = this.FormData.uuid;
      }
      this.FormData.listAcceptItems = this.listAcceptItems;
      let data = this.FormData;
      this.sLoading = true;
      // 创建分类
      ApiRequest(
        this.requestApi.updatePlatCategory.url,
        this.requestApi.updatePlatCategory.type,
        data,
        false
      )
        .then(res => {
          if (res.retStatus === '1') {
            this.sLoading = false;
            this.$Message.success('保存成功');
            this.$router.go(-1);
          }
        })
        .catch(err => {
          this.sLoading = false;
        });
    },
    handleReset () {
      this.$router.go(-1);
    },
    qualiByCommodityFun (row) {
      row.forEach(item => {});
    },
    qualiByClassifyFun (row) {
      row.forEach(item => {});
    },
    linkAttributeSupply (uuid, type) {
      if (type === '0') {
        // 取消关联
        let data = {
          platCategoryUuid: this.uuid,
          templateUuidList: uuid
        };
        // 创建分类
        ApiRequest(
          this.requestApi.deleteRelation.url,
          this.requestApi.deleteRelation.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkAttributeChang(this.linkAttributeValue);
          }
        });
      } else {
        let data = {
          platCategoryUuid: this.uuid,
          templateUuidList: uuid
        };
        // 创建分类
        ApiRequest(
          this.requestApi.bathCreatePlatCategoryAndTemplate.url,
          this.requestApi.bathCreatePlatCategoryAndTemplate.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkAttributeChang(this.linkAttributeValue);
          }
        });
      }
    },
    linkBrandSupply (uuid, type) {
      if (type === '0') {
        // 取消关联
        let data = {
          platCategoryUuid: this.uuid,
          brandUuidList: uuid
        };
        ApiRequest(
          this.requestApi.deleteRelationPp.url,
          this.requestApi.deleteRelationPp.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkBrandChang(this.linkBrandValue);
          }
        });
      } else {
        let data = {
          platCategoryUuid: this.uuid,
          brandUuidList: uuid
        };
        ApiRequest(
          this.requestApi.bathCreatePlatCategoryAndBrandPp.url,
          this.requestApi.bathCreatePlatCategoryAndBrandPp.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkBrandChang(this.linkBrandValue);
          }
        });
      }
    },
    linkGatherSupply (uuid, type) {
      if (type === '0') {
        // 取消关联
        let data = {
          categoryUuid: this.uuid,
          relUuids: uuid
        };
        ApiRequest(
          this.requestApi.deleteRelateYs.url,
          this.requestApi.deleteRelateYs.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkGatherChang(this.linkGatherValue);
          }
        });
      } else {
        let data = {
          categoryUuid: this.uuid,
          relUuids: uuid
        };
        let data1 = [];
        data1.push(this.linkGatherData[index]);
        ApiRequest(
          this.requestApi.createRelateYs.url + '?categoryUuid=' + this.uuid,
          this.requestApi.createRelateYs.type,
          data1,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkGatherChang(this.linkGatherValue);
          }
        });
      }
    },
    linkCategorySupply (uuid, type) {
      if (type === '0') {
        // 取消关联
        let data = {
          categoryUuid: this.uuid,
          relUuids: uuid
        };
        // 创建分类
        ApiRequest(
          this.requestApi.deleteRelateGl.url,
          this.requestApi.deleteRelateGl.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkCategoryChang(this.linkCategoryValue);
          }
        });
      } else {
        let data = {
          categoryUuid: this.uuid,
          relUuids: uuid
        };
        // 创建分类
        ApiRequest(
          this.requestApi.createRelateByCateGl.url,
          this.requestApi.createRelateByCateGl.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkCategoryChang(this.linkCategoryValue);
          }
        });
      }
    },
    linkSceneSupply (uuid, type) {
      if (type === '0') {
        // 取消关联
        let data = {
          categoryUuid: this.uuid,
          relUuids: uuid
        };
        ApiRequest(
          this.requestApi.deleteRelateCj.url,
          this.requestApi.deleteRelateCj.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkSceneChang(this.linkSceneValue);
          }
        });
      } else {
        let data = {
          categoryUuid: this.uuid,
          relUuids: uuid
        };
        ApiRequest(
          this.requestApi.createRelateCj.url,
          this.requestApi.createRelateCj.type,
          data,
          true
        ).then(res => {
          if (res.retStatus === '1') {
            this.linkSceneChang(this.linkSceneValue);
          }
        });
      }
    },
    closeModal () {
      this.initData();
    },
    handleChangePage (val) {
      this.pageShow = val;
      this.$nextTick(() => {
        // this.getData()
      });
    }
  }
};
</script>
